package main.states;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.geom.Rectangle2D;

import main.GamePanel;

public class MenuState extends GameState {
	
	//private Background bg;
	private Font defaultFont;
	private Font titleFont;
	private Color titleColor;
	
	private int currentchoice;
	private String[] options ={"Start","Help","Quit"};

	public MenuState(GameStateManager gsm) {
		this.gsm = gsm;
		this.currentchoice = 0;
		titleColor = new Color(128,0,0);
		titleFont = new Font("Gill Sanz",Font.PLAIN,35);
		defaultFont = new Font("Gill Sanz",Font.PLAIN,25);
		
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void update() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void draw(Graphics2D g) {
		//draw bg
		g.setColor(Color.black);
		g.fill(new Rectangle2D.Double(0, 0,
		        GamePanel.WIDTH, GamePanel.HEIGHT));
		
		//draw title
		g.setColor(titleColor);
		g.setFont(titleFont);
		g.drawString("Projecto Caos", (GamePanel.WIDTH/2)-87, 70);
		
		//draw options
		g.setFont(titleFont);
		for(int k = 0; k<options.length;k++){
			if(k==currentchoice){
				g.setColor(Color.WHITE);
				g.setFont(defaultFont);
				g.drawString(options[k], (GamePanel.WIDTH/2)-40, 170+k*50);
			}else {
				g.setFont(defaultFont);
				g.setColor(Color.DARK_GRAY);
			g.drawString(options[k], (GamePanel.WIDTH/2)-40, 170+k*50);
			}
		}
		
		
	}
	@Override
	public void keyPressed(int k) {
		if(k == KeyEvent.VK_ENTER){
			select();
		}
		
		if(k == KeyEvent.VK_UP){
			currentchoice--;
			if(currentchoice == -1){currentchoice=2;}
		}

		if(k == KeyEvent.VK_DOWN){
			if(currentchoice == 2){currentchoice=0;}else{currentchoice++;}
		}
	}

	private void select() {
	if(currentchoice ==0) gsm.setState(1); 
		
	}

	@Override
	public void keyReleased(int k) {
		// TODO Auto-generated method stub
		
	}

}
